package lynch.core 
{
	import flash.display.Stage;
	import flash.errors.IllegalOperationError;
	import lynch.Core.config.ration.Core.config.
	import lynch.map.MiniMap;
	import lynch.map.WorldMap;
	import lynch.net.Client;
	import lynch.net.Server;
	import lynch.net.SocketConnector;
	import starling.core.Starling;
	/**
	 * games entry
	 * @author 小痛
	 */
	public class Core 
	{
		public static var map:WorldMap;
		public static var miniMap:MiniMap;
		public static var client:Client;
		public static var server:Server;
		
		/**
		 * @throws flash.errors.IllegalOperationError	no need to create an instance of Core
		 */
		public function Core()
		{
			throw new IllegalOperationError("no need to create an instance of Core");
		}
		
		public static function initialize():void
		{
			//------------Clear stage-------------------------
			var stage:Stage = Starling.current.nativeStage;
			//stage.removeChildAt(0);
			
			//------------GlobeCore.config.initialize---------------
			Core.config.stageWidth = stage.stageWidth;
			Core.config.stageHeight = stage.stageHeight;
			
			//------------net initialize---------------
			server = new Server();
			client = new Client();
			
			var connector:SocketConnector = SocketConnector.arcane::initialize();
			connector.receiveder = server.protocol;
			connector.connect(Core.config.SERVER_IP, Core.config.SERVER_PORT);
			
			//------------map initialize---------------
			map = new WorldMap();
			miniMap = map.getMiniMap();
		}
	}
}